package com.example.module_home.login

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import com.example.module_home.databinding.HomeActivityLoginBinding
import com.google.android.material.tabs.TabLayout

class LoginActivity : AppCompatActivity() {

    private lateinit var loginBinding: HomeActivityLoginBinding
    private lateinit var fragmentAdapter: FragmentAdapter

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        loginBinding = HomeActivityLoginBinding.inflate(LayoutInflater.from(this), null, false)
        setContentView(loginBinding.root)


        fragmentAdapter = FragmentAdapter(supportFragmentManager, arrayListOf("login", "signUp"))



        loginBinding.apply {

            viewpager.adapter = fragmentAdapter
            tablayout.addTab(loginBinding.tablayout.newTab().setText("login"))
            tablayout.addTab(loginBinding.tablayout.newTab().setText("signUp"))
            viewpager.addOnPageChangeListener(object :
                TabLayout.TabLayoutOnPageChangeListener(loginBinding.tablayout) {})
            tablayout.setupWithViewPager(viewpager)

            //设置初始偏移量
            fbInput.translationY = 300f
            fbSearch.translationY = 300f
            fbAdd.translationY = 300f
            tablayout.translationY = 300f
            viewpager.translationY = 300f

            //设置初始透明不可见
            fbInput.alpha = 0f
            fbSearch.alpha = 0f
            fbAdd.alpha = 0f
            tablayout.alpha = 0f
            viewpager.alpha = 0f

            fbInput.animate().alpha(1f).translationY(0f).setDuration(1000).setStartDelay(400)
                .start()
            fbSearch.animate().alpha(1f).translationY(0f).setDuration(1000).setStartDelay(600)
                .start()
            fbAdd.animate().alpha(1f).translationY(0f).setDuration(1000).setStartDelay(800)
                .start()
            tablayout.animate().alpha(1f).translationY(0f).setDuration(1000).setStartDelay(300)
                .start()
            viewpager.animate().alpha(1f).translationY(0f).setDuration(1000).setStartDelay(300)
                .start()


        }


    }


}